#!/bin/bash

randomNum() {
	if [ $# -eq 1 ];then
		(( rand = $RANDOM*$1/32767 ))
		echo $rand
	else
		echo $RANDOM
	fi
}

completar() {
	formedNumber=""
	if [ $# -eq 2 ];then
		(( max = $2 - 1 ))

		for (( i = $max; i >= 0; i-- ))
		do
			((tenth = 10 ** $i))
			if [ $1 -lt $tenth ];then
				formedNumber=$formedNumber"0"
			else
				formedNumber=$formedNumber"$1"
				break;
			fi
		done
		echo $formedNumber
	else
		echo "maaaaaaaal"
	fi
}

genRegistro() {

	codCampana=C
	descripcion="Campaña nro "
	tarEstandar=
	tarMes1=
	tarMes2=
	tarMes3=
	tarMes4=
	tarMes5=
	tarMes6=

	
	#var=`randomNum 999`
	var=`completar $1 2`
	codCampana=$codCampana$var

	descripcion=$descripcion$1

	var=`randomNum 99999`
	var=`completar $var 10`
	tarEstandar=$var

	var=`randomNum 99999`
	var=`completar $var 10`
	tarMes1=$var


	var=`randomNum 99999`
	var=`completar $var 10`
	tarMes2=$var


	var=`randomNum 99999`
	var=`completar $var 10`
	tarMes3=$var


	var=`randomNum 99999`
	var=`completar $var 10`
	tarMes4=$var


	var=`randomNum 99999`
	var=`completar $var 10`
	tarMes5=$var


	var=`randomNum 99999`
	var=`completar $var 10`
	tarMes6=$var


	registro=$codCampana","$descripcion","$tarEstandar","$tarMes1","$tarMes2","$tarMes3","$tarMes4","$tarMes5","$tarMes6
	echo $registro
}


for (( i = 1 ; i < 100 ; i++ ))
do
	registro=`genRegistro $i`
	echo $registro
done

